﻿// Decompiled with JetBrains decompiler
// Type: Netick.NetickBounds
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

using System;
using System.Numerics;
using System.Runtime.CompilerServices;

#nullable disable
namespace Netick;

[Serializable]
[method: MethodImpl(MethodImplOptions.AggressiveInlining)]
public struct NetickBounds(Vector3 center, Vector3 size) : IEquatable<NetickBounds>
{
  public Vector3 Center = center;
  public Vector3 Extents = Vector3.op_Multiply(size, 0.5f);

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public override int GetHashCode() => this.Center.GetHashCode() ^ this.Extents.GetHashCode() << 2;

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public override bool Equals(object other) => other is NetickBounds other1 && this.Equals(other1);

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public bool Equals(NetickBounds other)
  {
    return this.Center.Equals(other.Center) && this.Extents.Equals(other.Extents);
  }

  public Vector3 Size
  {
    [MethodImpl(MethodImplOptions.AggressiveInlining)] get => Vector3.op_Multiply(this.Extents, 2f);
    [MethodImpl(MethodImplOptions.AggressiveInlining)] set
    {
      this.Extents = Vector3.op_Multiply(value, 0.5f);
    }
  }

  public Vector3 Min
  {
    [MethodImpl(MethodImplOptions.AggressiveInlining)] get
    {
      return Vector3.op_Subtraction(this.Center, this.Extents);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)] set => this.SetMinMax(value, this.Max);
  }

  public Vector3 Max
  {
    [MethodImpl(MethodImplOptions.AggressiveInlining)] get
    {
      return Vector3.op_Addition(this.Center, this.Extents);
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)] set => this.SetMinMax(this.Min, value);
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public static bool operator ==(NetickBounds lhs, NetickBounds rhs)
  {
    return Vector3.op_Equality(lhs.Center, rhs.Center) && Vector3.op_Equality(lhs.Extents, rhs.Extents);
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public static bool operator !=(NetickBounds lhs, NetickBounds rhs) => !(lhs == rhs);

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void SetMinMax(Vector3 min, Vector3 max)
  {
    this.Extents = Vector3.op_Multiply(Vector3.op_Subtraction(max, min), 0.5f);
    this.Center = Vector3.op_Addition(min, this.Extents);
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void Encapsulate(Vector3 point)
  {
    this.SetMinMax(Vector3.Min(this.Min, point), Vector3.Max(this.Max, point));
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void Encapsulate(NetickBounds bounds)
  {
    this.Encapsulate(Vector3.op_Subtraction(bounds.Center, bounds.Extents));
    this.Encapsulate(Vector3.op_Addition(bounds.Center, bounds.Extents));
  }

  public void Expand(float amount)
  {
    amount *= 0.5f;
    this.Extents = Vector3.op_Addition(this.Extents, new Vector3(amount, amount, amount));
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public void Expand(Vector3 amount)
  {
    this.Extents = Vector3.op_Addition(this.Extents, Vector3.op_Multiply(amount, 0.5f));
  }

  [MethodImpl(MethodImplOptions.AggressiveInlining)]
  public bool Intersects(NetickBounds bounds)
  {
    return (double) this.Min.X <= (double) bounds.Max.X && (double) this.Max.X >= (double) bounds.Min.X && (double) this.Min.Y <= (double) bounds.Max.Y && (double) this.Max.Y >= (double) bounds.Min.Y && (double) this.Min.Z <= (double) bounds.Max.Z && (double) this.Max.Z >= (double) bounds.Min.Z;
  }
}
